import request from '@/utils/request'

export function getMenusTree() {
  return request({
    url: 'api/menu/tree',
    method: 'post'
  })
}

export function getMenus(data) {
  return request({
    url: 'api/menu/page',
    method: 'post',
    data
  })
}

export function add(data) {
  return request({
    url: 'api/menu/create',
    method: 'post',
    data
  })
}

export function del(ids) {
  const data = { ids: ids }
  return request({
    url: 'api/menu/delete',
    method: 'post',
    data
  })
}

export function edit(data) {
  return request({
    url: 'api/menu/update',
    method: 'post',
    data
  })
}

export function getChild(id) {
  const data = { id: id }
  return request({
    url: 'api/menu/child-ids',
    method: 'post',
    data
  })
}

export default { add, edit, del, getMenusTree, getMenus, getChild }
